﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Sunboxsoft.WinForm
{
    public class ActionNode
    {
        public string Caption { get; set; }
        public string Name { get; set; }
        public Action<object, object> ClickCallback { get; private set; }
        public List<ActionNode> Children { get; set; }
        public Image Image { get; set; }
        public Image LargeImage { get; set; }

        /// <summary>
        /// 是否显示
        /// </summary>
        public bool IsShow { get; set; }
        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnable { get; set; }
        

        /// <summary>
        /// 对应的UI上的对象
        /// </summary>
        [Obsolete("使用UIObject")]
        public List<object> UIObjects { get; private set; }

        /// <summary>
        /// 对应的UI上的对象
        /// </summary>
        public object UIObject { get; set; }

        public ActionNode(string name, string caption)
        {
            IsShow = true;
            IsEnable = true;
            Name = name;
            Caption = caption;
            UIObjects = new List<object>();
        }

        public ActionNode(string name, Image image, string caption)
        {
            IsShow = true;
            IsEnable = true;
            Name = name;
            Image = image;
            Caption = caption;
            UIObjects = new List<object>();
        }

        public ActionNode(string name, string caption, Action<object, object> clickCallback)
        {
            IsShow = true;
            IsEnable = true;
            Name = name;
            Caption = caption;
            ClickCallback = clickCallback;
            UIObjects = new List<object>();
        }

        public ActionNode(string name, Image image, string caption, Action<object, object> clickCallback)
        {
            IsShow = true;
            IsEnable = true;
            Name = name;
            Image = image;
            Caption = caption;
            ClickCallback = clickCallback;
            UIObjects = new List<object>();
        }

        public ActionNode(string name, Image image, Image largeImage, string caption, Action<object, object> clickCallback)
        {
            IsShow = true;
            IsEnable = true;
            Name = name;
            Image = image;
            LargeImage = largeImage;
            Caption = caption;
            ClickCallback = clickCallback;
            UIObjects = new List<object>();
        }

        public ActionNode AddChild(ActionNode node)
        {
            if (Children == null)
            {
                Children = new List<ActionNode>();
            }
            Children.Add(node);
            return this;
        }
    }
}
